package com.example.demo.impl;

import com.example.demo.entity.User;
import com.example.demo.entity.USERO;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zmh
 * @since 2021-06-30
 */
@Service

public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Resource
    public UserMapper userMapper;
    public List<User> getList() {
        return userMapper.findAll();
    }
    public List<USERO> getALLList() {
        return userMapper.findAllList();
    }
    public Object login(String username,String password)
    {
        return userMapper.chooseuser(username,password);
    }
    public boolean register(String username,String password)
    {
        if(userMapper.selectuser(username)==null) {
            userMapper.adduser(username, password);
            return true;
        }
        return false;
    }
    public boolean isvip(String username)
    {
        if( userMapper.isvip(username).equals(1))return true;
        return  false;
    }

    public List<User> findms(String name)
    {
        return userMapper.finduserms(name);
    }

    public boolean insert(String name,String username,String address,String phonenumber,String Email,String sex)
    {
        userMapper.addusers(name,username,address,phonenumber,Email,sex);
        return  true;
    }

    public String findby_oid(String openID)
    {
        return userMapper.findby_oid(openID);
    }

    public boolean addhuaweiuser(String username,String openID)
    {
        userMapper.addhuaweiuser(username, openID);
        return true;
    }

    public boolean addhuaweiuserms(String name,String username,String phonenumber,String Email,String sex)
    {
        userMapper.addhuaweiuserms(name, username, phonenumber, Email, sex);
        return true;
    }

    public boolean updatevip(String username)
    {
        userMapper.updatevip(username);
        return  true;
    }

}
